package com.iflytek.yly.jetpackdemo.lifecycle;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

public class LifeCycleDemo2Activity extends AppCompatActivity {

    private MyLocationListener myLocationListener;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        myLocationListener = new MyLocationListener(this,
                new MyLocationListener.OnLocationChangeListener() {
                    @Override
                    public void onChanged(double latitude, double longitude) {
                        //展示收到的位置信息
                    }
                });

        // 将观察者与被观察者绑定
        getLifecycle().addObserver(myLocationListener);
    }
}